<template>
  <div class="app-container">
    <el-card>
      <el-form size="small" :model="searchForm" inline>
        <el-form-item label="公司名称：">
          <el-input
            v-model="searchForm.enterpriseName"
            placeholder="请输入公司名称"
            clearable
          />
        </el-form-item>
        <el-form-item label="税号：">
          <el-input v-model="searchForm.creditCode" placeholder="请输入税号" />
        </el-form-item>
        <el-form-item label="法人姓名：">
          <el-input
            v-model="searchForm.legalPerson"
            placeholder="请输入法人姓名"
          />
        </el-form-item>

        <!--        <el-form-item label="所属省份：">-->
        <!--          <el-select-->
        <!--            filterable-->
        <!--            clearable-->
        <!--            style="width: 200px"-->
        <!--            v-model="searchForm.areaId"-->
        <!--            placeholder="请选择所属省份"-->
        <!--          >-->
        <!--            <el-option-->
        <!--              v-for="item in provinceList"-->
        <!--              :key="item.id"-->
        <!--              :label="item.name"-->
        <!--              :value="item.id"-->
        <!--            />-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->

        <el-form-item>
          <el-button icon="el-icon-refresh" @click="reset()">重置</el-button>
          <el-button type="primary" icon="el-icon-search" @click="getList"
            >查询</el-button
          >
        </el-form-item>
      </el-form>
      <el-table v-loading="listLoading" :data="tabaleData.data" border>
        <el-table-column
          prop="id"
          label="序号"
          type="index"
          width="50"
          align="center"
        />
        <el-table-column
          prop="enterpriseName"
          label="企业名称"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="creditCode"
          label="统一信用代码"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="legalPerson"
          label="法人姓名"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="createTime"
          label="查询时间"
          align="center"
        ></el-table-column>
        <el-table-column label="状态" align="center">
          <template slot-scope="scope">
            <el-tag
              size="small"
              type="info"
              disable-transitions
              v-if="scope.row.queryStatus == 1"
              >查询中</el-tag
            >
            <el-tag
              size="small"
              type="success"
              disable-transitions
              v-if="scope.row.queryStatus == 2"
              >查询成功</el-tag
            >

            <el-tag
              size="small"
              type="danger"
              disable-transitions
              v-if="scope.row.queryStatus == 3"
              >查询失败</el-tag
            >
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100" align="center">
          <template slot-scope="scope">
            <el-button
              :disabled="scope.row.queryStatus != 2"
              type="text"
              size="small"
              @click="seeDetail(scope.row)"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        class="pageRight"
        :current-page="searchForm.pageNum"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="searchForm.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="tabaleData.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>
    <dialog-diy :title="'详情'" ref="dialogDiy" @handleClose="handleClose">
      <div style="height: 70vh; overflow-y: auto">
        <el-tabs v-model="activeName">
          <el-tab-pane label="基本信息" name="first">
            <basic-info
              :detailInfo="detailInfo"
              v-if="activeName === 'first'"
            />
          </el-tab-pane>
          <el-tab-pane label="工商股东信息" name="second">
            <gs-info :detailInfo="detailInfo" v-if="activeName === 'second'" />
          </el-tab-pane>
          <el-tab-pane label="工商司法信息" name="third">
            <gssfInfo :detailInfo="detailInfo" v-if="activeName === 'third'" />
          </el-tab-pane>
        </el-tabs>
      </div>
    </dialog-diy>
  </div>
</template>
<script>
import { getProvinceList } from "@/api/tax";
import dialogDiy from "../../../components/dialogDiy/index.vue";
import basicInfo from "./components/basicInfo.vue";
import gssfInfo from "./components/gssfInfo.vue";
import gsInfo from "./components/gsInfo.vue";
import { getBusinessCirclesList } from "@/api/report";
export default {
  components: {
    dialogDiy,
    basicInfo,
    gsInfo,
    gssfInfo
  },
  name: "index",
  data() {
    return {
      searchForm: {
        pageNum: 1,
        pageSize: 10,
        enterpriseName: "",
        creditCode: "",
        legalPerson: "",
        areaId: ""
      },
      tabaleData: {
        data: [],
        total: 0
      },
      listLoading: false,
      activeName: "first",
      detailInfo: {},
      provinceList: []
    };
  },
  created() {
    const p1 = getProvinceList();
    Promise.all([p1]).then(res => {
      this.provinceList = res[0].data;
      this.getList();
    });
  },
  methods: {
    seeDetail(v) {
      this.$router.push({
        path: "/businessCircles/detail",
        query: {
          id: v.id
        }
      });
      // this.detailInfo = v;
      // this.$refs.dialogDiy.openlog();
    },
    handleClose() {
      this.activeName = "first";
    },
    reset() {
      this.searchForm = {
        pageNum: 1,
        pageSize: 10,
        enterpriseName: "",
        creditCode: "",
        legalPerson: "",
        areaId: ""
      };
      this.getList();
    },
    handleSizeChange(val) {
      this.searchForm.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.searchForm.pageNum = val;
      this.getList();
    },
    getList() {
      this.listLoading = true;
      getBusinessCirclesList(this.searchForm)
        .then(res => {
          this.tabaleData.data = res.data.list;
          this.tabaleData.total = res.data.total;
          this.listLoading = false;
        })
        .finally(() => {
          this.listLoading = false;
        });
    }
  }
};
</script>

<style scoped lang="scss"></style>
